package com.pontodroid;

import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

public class DataBaseCreate extends SQLiteOpenHelper {

	
	private static final String cosnt_DATABASE_NAME = "PontoDroid.db";
	private static final int cosnt_DATABASE_VERSION = 1;	

	public DataBaseCreate(Context context) {
		super(context, cosnt_DATABASE_NAME, null, cosnt_DATABASE_VERSION);
	}

	@Override
	public void onCreate(SQLiteDatabase arg0) {
	
	}

	@Override
	public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
		db.execSQL("DROP TABLE IF EXISTS nomeTabela");
		onCreate(db);		
	}
	
	public boolean ExisteTabelaCriada(SQLiteDatabase db, String NOME_TABELA) {
		boolean retorno_bool = true;
		Cursor c = db.rawQuery(
				"SELECT NAME FROM sqlite_master WHERE type='table' AND name='"
						+ NOME_TABELA + "'", null);
		if (c.getCount() == 0) {
			retorno_bool = false;
		}
		return retorno_bool;
	}	
	
	public SQLiteDatabase retornaBaseDados() {
		return getWritableDatabase();
	}	

}
